const util = {
	timestampToDate(timestamp, formatter = 'Y-m-d H:i:s') {
		const date = new Date(timestamp); // 如果timestamp是数值，则直接使用，否则需要转换
		const year = date.getFullYear();
		const month = (date.getMonth() + 1).toString().padStart(2, '0');
		const day = date.getDate().toString().padStart(2, '0');
		const hours = date.getHours().toString().padStart(2, '0');
		const minutes = date.getMinutes().toString().padStart(2, '0');
		const seconds = date.getSeconds().toString().padStart(2, '0');

		if (formatter == 'Y-m-d H:i:s') {
			return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
		} else if (formatter == 'Y年m月d日 H:i:s') {
			return `${year}年${month}月${day}日 ${hours}:${minutes}:${seconds}`;
		} else if (formatter == 'Y-m-d H:i') {
			return `${year}-${month}-${day} ${hours}:${minutes}`;
		} else if (formatter == 'Y年m月d日 H:i') {
			return `${year}年${month}月${day}日 ${hours}:${minutes}`;
		} else if (formatter == 'Y-m-d') {
			return `${year}-${month}-${day}`;
		} else if (formatter == 'Y年m月d日') {
			return `${year}年${month}月${day}日`;
		}
	}
}

export default util;